import React, { Component } from 'react'
import { Flex, Button } from 'react-vant'

//封装组件 tap切换功能 动态传入的数据
export default class Mytao extends Component {


    render() {

        let { data, dataIndex, setIndex } = this.props
        //console.log(this.props);
        return (
            <div>
                <Flex gutter={16} wrap='wrap'>
                    {
                        data.map((item, index) => {
                            return <Flex.Item span={8} key={index}>
                                <Button block 
                                type={dataIndex==index?'danger':'default'}
                                 size='small' onClick={()=>{
                                    setIndex(index)
                                 }}>{item}元</Button>
                            </Flex.Item>
                        })
                    }
                </Flex>
            </div >
        )
    }
}
